<!DOCTYPE html>
<html>
<head>
    <title>分类管理</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">

    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/fontawesome.min.css">
    <link rel="stylesheet" href="/css/AdminLTE.min.css">
    <link rel="stylesheet" href="/css/_all-skins.min.css">
    <link rel="stylesheet" href="/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="/css/jquery.fileupload.css">
    <link rel="stylesheet" href="/css/main.css">

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div id="app" class="wrapper" v-cloak>

    <main-header></main-header>
    <main-sidebar></main-sidebar>
    <!-- =============================================== -->
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <content-header title="分类管理"></content-header>
        <!-- Main content -->
        <section class="content">
            <div v-show="showList">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">列表</h3>
                    </div><!-- /.box-header -->
                    <div class="box-body">
                        <div class="form-group">
                            <a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
                            <a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
                            <a class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
                        </div>
                        <table id="table"></table>
                    </div>
                </div>
            </div>

            <div v-show="!showList">
                <div class="box">
                    <div class="box-header with-border">
                        <h3 class="box-title">{{title}}</h3>
                    </div><!-- /.box-header -->
                    <div class="box-body">
                        <form class="form-horizontal">
                            <div class="form-group">
                                <div class="col-sm-2 control-label">分类名称<span class="text-danger">*</span></div>
                                <div class="col-sm-7">
                                    <input type="text" class="form-control" v-model="category.categoryName"
                                           placeholder="分类名称"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2 control-label">排序</div>
                                <div class="col-sm-7">
                                    <input type="number" class="form-control" v-model="category.sort" placeholder="排序"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-2 control-label"></div>
                                <input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
                                &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

        </section>
    </div>
</div>
<script src="/css/jquery.min.js"></script>
<script src="/css/vue.min.js"></script>
<script src="/css/bootstrap.min.js"></script>
<script src="/css/bootstrap-table.min.js"></script>
<script src="/css/app.js"></script>
<script src="/css/jquery.ui.widget.js"></script>
<script src="/css/jquery.fileupload.js"></script>
<script src="/js/admin/components.js"></script>
<script src="/js/admin/common.js"></script>
<script src="/js/admin/book/category.js"></script>

<script type="text/javascript">
    $(function () {
        // Change this to the location of your server-side upload handler:
        var url = "/api/fileupload/upload";
        $('#fileupload').fileupload({
            url: url,
            dataType: 'json',
            acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
            maxFileSize: 10240,
            done: function (e, data) {
                if (data.result.code == 0) {
                    $("#picUrl").attr("src", data.result.url);
                    vm.category.picUrl = data.result.url;
                }
            }
        }).prop('disabled', !$.support.fileInput)
            .parent().addClass($.support.fileInput ? undefined : 'disabled');
    })

</script>

</body>
</html>